import mockjs from 'mockjs';
const Random = mockjs.Random;
const water = require('./data/water.json');
const users = require('./data/users.json');

export default {
  '/api/water': water,
  '/api/users': users,
    // 使用 mockjs 等三方库
  'GET /api/tags': {
    '/': mockjs.mock({
      'list|100': [{ name: '@city', 'value|1-100': 50, 'type|0-2': 1 }],
    }),
  },

  'POST /api/auth_routes': {
    '/': { role: 'admin' },
  },
  // 支持自定义函数
  'POST /api/users/create': (req, res) => { 
    setTimeout(function () {
      res.end('OK111'); 
    }, 2000);
   },
   
   'GET /api/v1/admin/currentUser':(req, res) => {
            res.send({
                status: 'success',
                code: 0,
                message: '成功',
                data: {
                    id: 1,
                    name: '杨圆建',
                }
            });
    
    },
    'GET /api/shop/cart': mockjs.mock({
              'data|8': [{
                  name: Random.ctitle(8,18),
                  'id|1-100': 1,
                  'count|1-10': 1,
                  'cover': Random.image('64x64', '#00405d', '#FFF', 'image'),
                  'cost_price|5-22.1-2': 10.1,
                  'suggested_price|22-42.1-2': 10.1
              }],
    }),
  }